import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AdmBookBorrowVO, AdmBookBorrowForm, AdmBookBorrowQuery } from '@/api/general/administration/book/borrow/types';

/**
 * 查询图书借阅列表
 * @param query
 * @returns {*}
 */

export const listAdmBookBorrow = (query?: AdmBookBorrowQuery): AxiosPromise<AdmBookBorrowVO[]> => {
  return request({
    url: '/system/admBookBorrow/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询图书借阅详细
 * @param id
 */
export const getAdmBookBorrow = (id: string | number): AxiosPromise<AdmBookBorrowVO> => {
  return request({
    url: '/system/admBookBorrow/' + id,
    method: 'get'
  });
};

/**
 * 新增图书借阅
 * @param data
 */
export const addAdmBookBorrow = (data: AdmBookBorrowForm) => {
  return request({
    url: '/system/admBookBorrow',
    method: 'post',
    data: data
  });
};

/**
 * 修改图书借阅
 * @param data
 */
export const updateAdmBookBorrow = (data: AdmBookBorrowForm) => {
  return request({
    url: '/system/admBookBorrow',
    method: 'put',
    data: data
  });
};

/**
 * 删除图书借阅
 * @param id
 */
export const delAdmBookBorrow = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/admBookBorrow/' + id,
    method: 'delete'
  });
};

/**
 * 批量添加图书
 * @param data 批量添加图书的请求参数
 * @returns
 */
export function batchAddBooks(data: any) {
  return request({
    url: '/system/admBookBorrow/batchAdd',
    method: 'post',
    data
  })
}